<template>
    <div style="height:50px;line-height: 50px;border-bottom: 1px solid #ccc; display: flex">
            <div style="width: 200px;padding-left: 30px;font-weight: bold;color: #42b983;">西华大学在线考试系统</div>
            <div style="flex: 1"></div>
            <div style="width: 100px;float: right;">
                <el-dropdown>
                    <span class="el-dropdown-link">
                        {{ user.studentName}}
                        <i class="el-icon-arrow-down" style="margin-left: 5px"></i>
                    </span>
                    <template #dropdown>
                    <el-dropdown-menu>
                        <el-dropdown-item>个人信息</el-dropdown-item>
                        <el-dropdown-item><div style="text-decoration: none" @click="logout">退出</div></el-dropdown-item>
                    </el-dropdown-menu>
                </template>
                </el-dropdown>
            </div>
    </div>
</template>

<script>


    export default {
        name: "Header",
        data(){
            return{
                user:localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")):{},
            }
        },
        components: {},
        methods:{
            logout(){
                localStorage.removeItem("user"); //删除应用程序的user
                this.$router.push('/login');
                this.$message.success("退出成功")
            },
        }
    }


</script>

<style scoped>

</style>



